You said:
Uploaded a file
Generate a excel file from a json input
This is a copy of a conversation between ChatGPT & Anonymous.
The Excel file has been generated from the JSON input. You can download it using the link below:
Download B2B_Invoices_Extracted.xlsx
It contains all B2B invoice details such as CTIN, invoice number, date, taxable value, GST amounts, and more. Let me know if you want to include other sections like B2CL, B2CS, or HSN-wise details.
Here's a Python script that reads a JSON file with GSTR-1 B2B invoice data and generates an Excel file from it using pandas and openpyxl.
You can run this script locally or integrate it into your automation tools:
pythonimport json
import pandas as pd
# Input and output file paths
json_file_path = "returns_26012021_R1_33AAYCS3291C2Z3_offline_others_0.json"
output_excel_path = "B2B_Invoices_Extracted.xlsx"
# Load JSON data
with open(json_file_path, 'r', encoding='utf-8') as f:
data = json.load(f)
# Process B2B invoices
records = []
for b2b_entry in data.get("b2b", []):
ctin = b2b_entry.get("ctin")
for inv in b2b_entry.get("inv", []):
for item in inv.get("itms", []):
itm_det = item.get("itm_det", {})
records.append({
"CTIN": ctin,
"Invoice No": inv.get("inum"),
"Invoice Date": inv.get("idt"),
"Invoice Value": inv.get("val"),
"Place of Supply": inv.get("pos"),
"Reverse Charge": inv.get("rchrg"),
"Invoice Type": inv.get("inv_typ"),
"Tax Rate (%)": itm_det.get("rt"),
"Taxable Value": itm_det.get("txval"),
"CGST Amount": itm_det.get("camt"),
"SGST Amount": itm_det.get("samt"),
"CESS Amount": itm_det.get("csamt"),
})
# Convert to DataFrame and export to Excel
df = pd.DataFrame(records)
df.to_excel(output_excel_path, index=False)
print(f"Excel file created: {output_excel_path}")
Make sure you install the necessary packages if not already installed:
bashpip install pandas openpyxl
Let me know if you also want to extract other sections like b2cl, b2cs, cdnr, etc. – I can extend this script accordingly.
Your Streamlit app has been created! It allows users to upload a GSTR-1 JSON file and download an Excel file with B2B invoice details.
To run it locally:
Save the script as app.py.
Install Streamlit: pip install streamlit
Run the app:
bashstreamlit run app.py
Let me know if you'd like to:
Add support for other sections like B2CL/B2CS/HSN.
Preview the data in the browser before download.
Deploy it online (e.g., via Streamlit Cloud or Hugging Face Spaces).
This “missing ScriptRunContext! This warning can be ignored when running in bare mode.” message is not an error — it’s a harmless warning from Streamlit's internal logging system.
You're likely:
Running the Streamlit app inside an interactive environment (e.g., Jupyter Notebook or IPython terminal), or
You've executed the app via exec() or embedded it in a custom script context.
Run the command again from a regular terminal, like this:
bashstreamlit run code2.py
Then check the output — it should say something like:
nginxLocal URL: http://localhost:8501
Manually open a browser and go to: http://localhost:8501
Let’s double-check a few things:
Are you running this inside a Jupyter notebook or embedded environment? If yes, exit and try a terminal/command prompt.
Are you using an IDE like PyCharm/VSCode? Try running it in the terminal window within the IDE, not via the "Run Script" button.
Is streamlit installed in the environment you're using? Confirm with:
bashpip show streamlit
Would you like me to help package it as a .bat or .sh launcher or deploy it to Streamlit Cloud for one-click access?
Some cookies are essential for this site to function and cannot be turned off. Others are set to help us understand how our service performs and is used, and to support our marketing efforts. Learn more in our Cookie Policy. For more info or to customize your preferences, tap ‘Manage Cookies’.